<template>
   <PanelSplitTwo bottomToolbarHeight="0" :num="2">
    <template #top>
      <SetUserSelect
        class="queryForm"
        v-model:formData="orderSelect"
        v-model:queryParams="paginationParams"
        @selectFunc="selectFunc"
      ></SetUserSelect>
    </template>
     <template #centerToolbar>
        <div class="vex_flex">
          <el-row :gutter="20" style="margin-bottom: 10px">
            <el-col :span="1.5">
              <el-button @click="handleQuery(0)">新增</el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button :disabled="selectedList.length !=1" @click="handleQuery(1)">修改</el-button>
            </el-col>
            <!-- <el-col :span="1.5">
              <el-button @click="handleQuery">取消</el-button>
            </el-col> -->
          </el-row>
        <VxeTableGrid
          style="flex: 1;"
          :tableColumn="tableColumn"
          :tableLoading="tableLoading"
          :dataList="dataList"
          :showPagination="true"
          :paginationParams="paginationParams"
          @getList="setQueryParams"
          @selectedChange="selectedChange"
        >
        </VxeTableGrid>
      </div>
     </template>
   </PanelSplitTwo>
</template>

<script setup lang="jsx">
import { useRouter } from 'vue-router'
import { articleList, delarticle  } from "@/api/article";
import { getCurrentInstance, ref } from "vue";
import datas from './data.js'
let keys = ref(0);
const { paginationParams, orderSelect }  = datas
const { proxy } = getCurrentInstance();
const router= useRouter ()
const dialogVisible = ref(false)
const handleClose = () => {
  dialogVisible.value = false
}
const { article_ma_status, article_ma_type } = proxy.useDict("article_ma_status", "article_ma_type");


const dataLists = ref([])
const tableColumn = ref([
  { type: "checkbox", width: 60, fixed: null },
  { field: "title", title: "标题" },
  { field: "type", title: "分类",
  slots: { default: ({ row }, h) => {
    return [<dict-tag options={ article_ma_type.value } value={ row.type }></dict-tag>]
  }} },
  { field: "author", title: "作者"},
  { field: "publicTime", title: "发表时间"},
  { field: "status", title: "状态",
  slots: { default: ({ row }, h) => {
    return [<dict-tag options={ article_ma_status.value } value={ row.status }></dict-tag>]
  }} },
])
const onlineList = ref([]);
const total = ref(0);
const pageNum = ref(1);
const pageSize = ref(10);
let tableLoading = ref(false)
const dataList = ref([])

const queryParams = ref({
  ipaddr: undefined,
  userName: undefined
});
// 切换分页
  function setQueryParams(val) {
    console.log(val)
    paginationParams.pageNum = val.pageNum;
    paginationParams.pageSize = val.pageSize;
    hospitalLists()
  }
  let Id = ref('')
  // 选择表格
  let selectedList = ref([])
  function selectedChange(val) {
    Id.value = val.currentItem.id
    selectedList.value = val.selectedList
  }
/** 新增|修改 */
function handleQuery(type) {
  router.push({
    path: '/article/addArticle',
    query: {
      id: type == 1? Id.value : undefined,
      type: type == 1? undefined : 'add'
    }
  })
}

const hospitalLists = () => {
  // platformNum
  articleList({
    ...paginationParams.value,
  }).then((res) => {
    paginationParams.value.total = res.total
    dataList.value = res.rows
  })
}
hospitalLists()
const selectFunc = () => {
  paginationParams.value.pageNum = 1
  hospitalLists()
}
</script>
<style scoped>
  .app-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 85px);
    overflow: hidden;
  }
  .vex_flex {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
  }
  .flexmin {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
</style>